import { ApiProperty, OmitType, PartialType } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { IsNotEmpty, IsOptional, IsString, MinLength } from "class-validator";

import { CreateFileDto } from "./create-file.dto";

export class UpdateFileDto extends PartialType(OmitType(CreateFileDto, ["hash", "origin"] as const)) {
    @Transform(({ value }) => value.trim())
    @IsOptional()
    @IsString() // 不能过滤空字符串
    @IsNotEmpty()
    @MinLength(1)
    @ApiProperty({ description: "文件名称", example: "文件名称", required: false })
    name: string;
}
